<?php

class Twiggy_Application
{
    private $controller = null;
    private $config = null;
    private $layout = null;
    
    public function __construct()
    {
        // Make necessary initializations
        $this->config = new Zend_Config_Xml(BASE_DIR . '/config/twiggy.xml', 'production');

        $this->controller = Zend_Controller_Front::getInstance();
        $this->controller->setControllerDirectory(array(
            'default'	=> BASE_DIR . '/application/default/controllers',
            'admin'		=> BASE_DIR . '/application/admin/controllers',
            'calendar'	=> BASE_DIR . '/application/calendar/controllers',
        ));
        
        date_default_timezone_set('Europe/Berlin');
        
        Zend_Layout::startMvc();
        $this->layout = Zend_Layout::getMvcInstance();
        
        // Custom routes
        $router = $this->controller->getRouter();
        $route = new Zend_Controller_Router_Route('calendar/display/:year/:month', array('module'=>'calendar', 'controller'=>'index', 'action'=>'display',));
        $router->addRoute('calendar/display', $route);
    }
    
    public function run()
    {
        
        $this->controller->dispatch();
    }
}
